package com.acane.instagram.controller;

import com.acane.instagram.pojo.Result;
import com.acane.instagram.service.LikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/like")
public class LikeController {
    @Autowired
    private LikeService likeService;

    @GetMapping("/history")
    public Result getLikeHistory(@RequestParam String userId) {
        return likeService.getLikeHistory(userId);
    }

    @GetMapping("/isLike")
    public Result judgeIfAlreadyLike(@RequestParam String postId, @RequestParam String likerId) {
        return Result.success(likeService.judgeIfAlreadyLike(postId, likerId));
    }

    @GetMapping("/count/get")
    public Result getCommentCount(@RequestParam String postId) {
        return Result.success(likeService.countByPostId(postId));
    }
}
